package com.geoboard.service;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.widget.Toast;

import com.android.volley.Response;
import com.geoboard.application.GeoBoardApplication;
import com.geoboard.entity.User;

public class PostUserListener implements Response.Listener<User>{
	
	private Activity mContext;
	
	public PostUserListener (Activity context) {
		mContext = context;
	}

	@Override
	public void onResponse(User user) {
		SharedPreferences sharedPref = mContext.getPreferences(Context.MODE_PRIVATE);
		sharedPref.edit().putString("com.geoboard.entity.user.name", user.getUserName()).commit();
		sharedPref.edit().putString("com.geoboard.entity.user.id", user.getId()).commit();
		GeoBoardApplication.setUser(user);
		Toast.makeText(mContext, String.format("account '%s' created!",
				user.getUserName())
				, Toast.LENGTH_SHORT).show();
	}
	

}
